$(document).ready(function(){

    $("#login-form").submit(function(event){

        var email = $("#log-email").val().trim();
        var password = $("#log-password").val().trim();

        if (email != "" && password != "") {
            if(isEmailAddress(email)){
                $("#log_error").hide();
                return true;
            }
            else{
                $("#log_error").text("Not an email!");
                $("#log_error").css("display", "block");
                return false;
            }
        }
        else{
            $("#log_error").text("All fields must be filled!");
            $("#log_error").css("display", "block");
            return false;
        }

    });

    $("#log_close").click(function(e){
        $("#login-wind").hide();
    });
});

function isEmailAddress(email) {
    if(email == "admin")
        return true;

    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
};